<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Msg_insert extends CI_Controller {

	function __construct()
	{
		parent::__construct();
	}

	public function index()
	{
		$this->load->helper('date');
		$this->load->helper('url');
		$this->load->model('messagedata_m');
		if($_POST['readauth']=="最高阅读权限"){
			$readauth=3;
		}else if($_POST['readauth']=="普通阅读权限"){
			$readauth=2;
		}else{
			$readauth=1;
		}
		
		$data=array(
			'title'=>$_POST['title'],
			'username'=>$_POST['user'],
			'message'=>$_POST['msg'],
			'time'=>date("Y-m-d H:i:s"),
			'readauth'=>$readauth,
			'type'=>$_POST['types']
			);					
			$this->messagedata_m->msg_insert($data);
			$pages=$this->messagedata_m->msg_getpage(5);
			if($pages[1]!=0){
				$pages[0]++;
			}
			//var_dump($_POST);
			redirect('?count='.($pages[0]-1)*5,'refresh');	
	}

}
?>